package cn.funeralobjects.aoss.converter;

import cn.funeralobjects.aoss.enums.StorageClass;

import javax.persistence.AttributeConverter;

/**
 * Converter of StorageClass
 *
 * @author FuneralObjects
 * Create date: 2020/6/1 11:52 AM
 */
public class StorageClassConverter implements AttributeConverter<StorageClass, String> {

    @Override
    public String convertToDatabaseColumn(StorageClass attribute) {
        return attribute == null ? null : attribute.getStorageClassString();
    }

    @Override
    public StorageClass convertToEntityAttribute(String dbData) {
        return dbData == null ? null : StorageClass.of(dbData);
    }
}
